package pl.pw.mkmw.pnganimator.utils;

import java.awt.Color;

/**
 *
 * @author MK
 */
public class ColorUtils {

    /*
     * Returns finely formatted colors table.
     */
    public static String toFinePrint(Color[][] colors) {
        StringBuilder sb = new StringBuilder("");
        sb.append("============\n");
        for (int y = 0; y < colors.length; y++) {
            for (int x = 0; x < colors[0].length; x++) {
                sb.append(colors[y][x].getRed()).append(" ");
            }
            sb.append("\n");
        }
        sb.append("\n");

        sb.append("============\n");
        for (int y = 0; y < colors.length; y++) {
            for (int x = 0; x < colors[0].length; x++) {
                sb.append(colors[y][x].getGreen()).append(" ");
            }
            sb.append("\n");
        }
        sb.append("\n");

        sb.append("============\n");
        for (int y = 0; y < colors.length; y++) {
            for (int x = 0; x < colors[0].length; x++) {
                sb.append(colors[y][x].getBlue()).append(" ");
            }
            sb.append("\n");
        }
        sb.append("\n");

        sb.append("============\n");
        for (int y = 0; y < colors.length; y++) {
            for (int x = 0; x < colors[0].length; x++) {
                sb.append(colors[y][x].getAlpha()).append(" ");
            }
            sb.append("\n");
        }
        sb.append("\n");

        return sb.toString();
    }

    /*
     * Returns finely formatted three-dimensional [4][y][x] color table
     */
    public static String toFinePrint(int[][][] colors) {
        StringBuilder sb = new StringBuilder("");

        for (int i = 0; i < 4; i++) {
            sb.append("============\n");
            for (int y = 0; y < colors[0].length; y++) {
                for (int x = 0; x < colors[0][0].length; x++) {
                    sb.append(colors[i][y][x]).append(" ");
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        return sb.toString();
    }
}
